package com.gzu.ltms.controller;


import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.gzu.ltms.response.Response;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {


    @PostMapping("/login")
    public Response<String> login(@RequestParam("username") String username,
                                  @RequestParam("password") String password) {
        StpUtil.login(1001);
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        return Response.success(tokenInfo.tokenValue);
    }

    @PostMapping("/logout")
    public Response<String> logout() {
        StpUtil.logout(1001);
        return Response.success("登出成功");
    }
}
